package com.fuang.controller;

import rx.Observable;
import rx.Subscriber;

/**
 * Created by Fuang on 2018-1-28.
 */
public class Test {

    Observable<String> observable = Observable.create(new Observable.OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> subscriber) {
            subscriber.onNext("Hello RxJava");
            subscriber.onNext("I am hhh");
            subscriber.onCompleted();
        }
    });

    Subscriber<String> subscriber = new Subscriber<String>() {
        @Override
        public void onCompleted() {
            System.out.println("onCompleted");
        }

        @Override
        public void onError(Throwable e) {

        }

        @Override
        public void onNext(String s) {
            System.out.println("Subscriber" + s);
        }
    };

    public static void main(String[] args) {
        Test test = new Test();
        test.observable.subscribe(test.subscriber);
    }
}
